import React from 'react'
import {connect} from 'react-redux'
import {WingBlank} from "antd-mobile";
import constants from "../../../../../../../utils/constants";
import LvMark from "../../../../../../../shared-components/LvMark/LvMark";
import VIPIcon from "../../../../../../../res/images/web/my/vip kim@2x.png";

const GiftMsg = props => {

    const giftMsg = props.giftMsg
    console.log(giftMsg)


    // const {userMsg,} = props
    // const {nickname, viplevel, msg, uid, vip} = userMsg

    // Gold: 1
    // Id: 9
    // Name: "爱心"
    // UsePack: false
    // anchorName: "平台"
    // c: 2
    // game: "中国女子足球超级联赛"
    // giftnum: 1
    // nickname: "Allen2"
    // selected: true
    // uid: "3b9ebae0-9049-4e65-959f-afb59f1a1ec4"
    // vip: 3
    // viplevel: 6
    const football = props.football
    const {
        uid,
        name,
        giftId,
        nickname,
        // giver,
        giftnum,
        viplevel,
        vip,
    } = giftMsg
    const isVip = vip > 0
    const currentUserId = localStorage.getItem('userid')
    const isMe = uid === currentUserId
    const textStyle = {
        fontWeight: isMe ? 600 : 'normal',
        color: isVip ? 'rgb(250,114,104)' : 'rgb(43, 138, 247)',
    }

    // const {
    //     // Viplevel,
    //     // nickname,
    //     uid,
    // } = giver

    // const name =
    let text = <span style={{fontSize: '14px', marginBottom: '2px', height: '24px', lineHeight: '24px',}}>(送出{name} x {giftnum})</span>
    if (football) {
        const game = props.game
        let team
        if (giftMsg.Who === 'zhu') {
            team = game.home_team
        } else if (giftMsg.Who === 'ke') {
            team = game.away_team
        }
        text = <span className='g-r-c-r-dialogue-user-msg-text'>{`为${team?.name_zh}送出了${name}！为${team?.name_zh}增加了${giftMsg.heat}点贡献热度值！`}</span>
    }
    return <WingBlank>
        <div className='g-r-c-r-dialogue-user-msg-c'>
            <div className='flex-center-align-center' style={{height: 24}}>
                <LvMark lv={viplevel}/>
                {isVip ? <img alt='' src={VIPIcon} style={{width: '34px',}}/> : null}
                <span className='g-r-c-r-dialogue-user-msg-name'
                      style={textStyle}
                >{isMe ? '我' : nickname}:</span>
            </div>
            {text}
        </div>




    </WingBlank>
}

const mapState = (state) => ({
    game: state.game.currentGame,
})

export default connect(mapState,)(GiftMsg)
